<?php
/**
 * AppVersionRepo.php
 *
 * @copyright   2023 thingsworld.com.cn - All Rights Reserved
 * @link        http://thingsworld.com.cn/
 * @author      stiffer.chen <chenl@thingsworld.com.cn>
 * @created     2023-04-26 17:21:44
 * @modified    2023-04-26 17:21:44
 *
 */

namespace App\Repositories;

use App\Models\ConfigDataModel;

class AppVersionRepo
{
    public static function android()
    {
        $data = ConfigDataModel::query()->where('code', 'like', "android%")->get()->keyBy('code')->toArray();

        $version = $data['android_version']['value'] ?? '';
        $url = $data['android_url']['value'] ?? '';
        $description = $data['android_description']['value'] ?? '';

        return [
            'version' => $version,
            'url' => $url,
            'description' => $description
        ];
    }

    public static function ios()
    {
        $data = ConfigDataModel::query()->where('code', 'like', "ios%")->get()->keyBy('code')->toArray();

        $version = $data['ios_version']['value'] ?? '';
        $url = $data['ios_url']['value'] ?? '';
        $description = $data['ios_description']['value'] ?? '';

        return [
            'version' => $version,
            'url' => $url,
            'description' => $description
        ];
    }
}